package com.aat.dxfy.jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.alibaba.druid.pool.DruidDataSource;

public class TestPku {
	private static String driver = "com.mysql.jdbc.Driver";
	private static String jdbcUrl = "jdbc:mysql://218.57.174.45:3366/pkuv2?useUnicode=true&characterEncoding=utf8";
	private static String user = "pkuserver";
	private static String passwd = "Ase.s3`w4rf_ef4f";

	private static String sql = "SELECT pid FROM pku_user u WHERE u.num='1403082295'";

	public static void query(Connection conn) {
		try {
			Statement st = conn.createStatement();
			ResultSet result = st.executeQuery(sql);
			while (result.next()) {
				String s = result.getString("pid");
				System.out.println(s);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) throws Exception {
		DruidDataSource dataS = new DruidDataSource();
		// config
		dataS.setDriverClassName(driver);
		dataS.setUrl(jdbcUrl);
		dataS.setUsername(user);
		dataS.setPassword(passwd);
		dataS.setMaxActive(100);
		dataS.setMinIdle(1);
		dataS.setInitialSize(1);
		//
		query(dataS.getConnection());
		//
		dataS.close();
	}

}
